home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 29
/
Volume 29 - JOGO DISK .iso
/
Games
/
jungle_adventure.swf
/
scripts
/
__Packages
/
GameSwing.as
< prev
next >
Wrap
Text File
|
2006-11-29
|
4KB
|
116 lines
class GameSwing extends SSObject
{
var classID = SSGlobal.CLSID_SWING;
var length = 300;
var totalTime = 4;
var timeOffset = 0;
var maxAngle = 60;
var maxRad = 0;
var ax = 0;
var ay = 0;
var vx = 0;
var vy = 0;
var ltr = false;
var ang = 0;
var editor_isItem = true;
var editor_name = "Swing";
var editor_args_names = ["totalTime","timeOffset","length","maxAngle"];
var editor_args_values = [GameSwing.prototype.totalTime,GameSwing.prototype.timeOffset,GameSwing.prototype.length,GameSwing.prototype.maxAngle];
var editor_args_types = ["number","number","number","number"];
var editor_args_options = [[1,30,1],[0,10,0.1],[100,800,50],[10,90,5]];
var editor_args_descriptions = ["","","",""];
var editor_args_mode = [0,0,0];
var editor_args_component = ["NumericStepper","NumericStepper","NumericStepper","NumericStepper"];
var editor_canChangeFrame = false;
function GameSwing(totalTime, timeOffset, length, maxAngle)
{
super();
if(totalTime)
{
this.totalTime = totalTime;
}
if(timeOffset)
{
this.timeOffset = timeOffset;
}
if(length)
{
this.length = length;
}
if(maxAngle)
{
this.maxAngle = maxAngle;
}
this.localLeft = - this.length;
this.localBottom = this.localRight = this.length;
this.maxRad = maxAngle / 180 * 3.141592653589793;
}
function onAddToWorld()
{
this.zone = new SSZone();
}
function onAddToScene()
{
this.getUpdates();
this.update(0.0001);
}
function onRemoveFromScene()
{
this.cancelUpdates();
}
function update()
{
var _loc3_ = (this.world.time + this.timeOffset) % this.totalTime;
var _loc4_ = 3.141592653589793 * _loc3_ / this.totalTime * 2;
var _loc2_ = Math.sin(_loc4_) * 3.141592653589793 * (this.maxAngle / 180);
this.ltr = _loc2_ > this.ang;
this.ang = _loc2_;
this.oax = this.ax;
this.oay = this.ay;
this.ax = (this.vx = Math.sin(_loc2_)) * this.length;
this.ay = (this.vy = Math.cos(_loc2_)) * this.length;
this.queueForDisplay();
}
function onCollision(obj)
{
}
function onDisplay(vp, elapsed)
{
this.target.clear();
this.target.lineStyle(4,13333275);
this.target.moveTo(0,0);
if(this.holding)
{
var _loc4_ = this.holding.swingDist * 0.5;
this.target.curveTo(this.vx * _loc4_,this.vy * _loc4_,this.holding.x - this.x,this.holding.y - this.y);
var _loc3_ = this.oax - this.ax;
var _loc2_ = this.oay - this.ay;
var _loc6_ = Math.sqrt(_loc3_ * _loc3_ + _loc2_ * _loc2_);
this.target.lineTo(this.ax + _loc3_ / elapsed * 0.1,this.ay + _loc2_ / elapsed * 0.1);
}
else
{
this.target.curveTo(this.ax * 0.4,this.ay * 0.6,this.ax,this.ay);
}
}
function editor_onDisplay(target, external)
{
var _loc2_ = (90 - this.maxAngle) / 180 * 3.141592653589793;
var _loc7_ = Math.cos(_loc2_);
var _loc6_ = Math.sin(_loc2_);
target.clear();
target.lineStyle(0,16742348);
target.beginFill(16742348,30);
target.lineTo(_loc7_ * this.length,_loc6_ * this.length);
var _loc4_ = (1.5707963267948966 - _loc2_) * 0.2;
var _loc5_ = 10;
while((_loc5_ = _loc5_ - 1) > -1)
{
_loc2_ += _loc4_;
target.lineTo(Math.cos(_loc2_) * this.length,Math.sin(_loc2_) * this.length);
}
target.lineTo(0,0);
target.endFill();
}
}